﻿# CMakeList.txt: 顶层 CMake 项目文件，在此处执行全局配置
# 并包含子项目。
#
cmake_minimum_required (VERSION 3.8)

project ("GameNetFrame")
message("GameNetFrame")

add_definitions(-DFG_DEBUG_MODE)
#add_definitions(-DOPEN_CMD_TEST)
if(MSVC)
	add_definitions(-D_CRT_SECURE_NO_WARNINGS)
else()
	add_definitions(-std=c++11)
endif(MSVC)

#protobuf-3.6.0
include(FindProtobuf)
find_package(Protobuf REQUIRED)
message("[ptotobuf]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
message("Protobuf_INCLUDE_DIR=${Protobuf_INCLUDE_DIR}")
if(CMAKE_BUILD_TYPE MATCHES "Debug")
	set(PROTOBUF_LIBRARY ${Protobuf_LIBRARY_DEBUG})
	set(PROTOBUF_LITE_LIBRARY ${Protobuf_LITE_LIBRARY_DEBUG})
else()
	set(PROTOBUF_LIBRARY ${Protobuf_LIBRARY_RELEASE})
	set(PROTOBUF_LITE_LIBRARY ${Protobuf_LITE_LIBRARY_RELEASE})
endif(CMAKE_BUILD_TYPE MATCHES "Debug")
message("PROTOBUF_LIBRARY=${PROTOBUF_LIBRARY}")
message("PROTOBUF_LITE_LIBRARY=${PROTOBUF_LITE_LIBRARY}")

#libevent-2.1.11.0
find_package(Libevent REQUIRED)
include(${Libevent_DIR}/LibeventConfig.cmake)
message("[libevent]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
message("Libevent_DIR=${Libevent_DIR}")
message("LIBEVENT_CMAKE_DIR=${LIBEVENT_CMAKE_DIR}")

#include(${Libevent_DIR}/LibeventConfig.cmake)
message("LIBEVENT_INCLUDE_DIRS=${LIBEVENT_INCLUDE_DIRS}")
if(CMAKE_HOST_WIN32)
	set(LIBEVENT_LIBRARIES ${LIBEVENT_SHARED_LIBRARIES})
	message("LIBEVENT_SHARED_LIBRARIES=${LIBEVENT_SHARED_LIBRARIES}")
else()
	set(LIBEVENT_LIBRARIES ${LIBEVENT_STATIC_LIBRARIES})
	message("LIBEVENT_STATIC_LIBRARIES=${LIBEVENT_STATIC_LIBRARIES}")
endif()

#set include path
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${Protobuf_INCLUDE_DIR} .)
message("CMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}")
include_directories(${CMAKE_INCLUDE_PATH})

# 包含子项目。
add_subdirectory ("Core")
add_subdirectory ("Protocol")
add_subdirectory ("ConfigPlugin")
add_subdirectory ("LogPlugin")
add_subdirectory ("NetPlugin")
add_subdirectory ("SecurityPlugin")
add_subdirectory ("Server")
add_subdirectory ("PluginLoader")
# 配置文件复制
add_subdirectory ("DataCfg")
# 配置脚本复制
add_subdirectory ("Scripts")